package c6.E3;

import java.util.ArrayList;
import java.util.Iterator;

public class E3 {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        list.add("张三");
        list.add("李四");
        list.add("王五");
        list.add("赵六");
        Iterator it = list.iterator();//返回一个list对象的迭代器
        while (it.hasNext()) {
            Object obj = it.next();
            System.out.println(obj);
        }
        System.out.println("for循环迭代集合");
        for (Object obj:list){
            System.out.println(obj);
        }
        }
}
